# version code 988
# Please fill out this stencil and submit using the provided submission script.

import random
from GF2 import one
from vecutil import list2vec
from independence import is_independent
from itertools import combinations


## Problem 1
def randGF2(): return random.randint(0,1)*one

a0 = list2vec([one, one,   0, one,   0, one])
b0 = list2vec([one, one,   0,   0,   0, one])

def choose_secret_vector(s,t):
    #print('s = '+str(s)+' t = '+str(t))
    u = list2vec([randGF2() for i in range(6)])
    while(not((a0*u == s) and (b0*u == t))):
        u = list2vec([randGF2() for i in range(6)])        
   # print('u = '+str(u))
    return u

def generate_vecs(v):
    

    V = ([ list2vec([randGF2() for i in range(6)]) for j in range(4)])
    V.append(v)
    return V
    
def test(vecs):
    return all(is_independent(list(sum(x,()))) for x in combinations(vecs,3))

def independent_vecs():
    a_b = list(zip(generate_vecs(a0),generate_vecs(b0)))
    while(not test(a_b)):
        a_b = list(zip(generate_vecs(a0),generate_vecs(b0)))
    return a_b

L = independent_vecs()
## Problem 2
# Give each vector as a Vec instance
secret_a0 = a0
secret_b0 = b0
secret_a1 = L[0][0]
secret_b1 = L[0][1]
secret_a2 = L[1][0]
secret_b2 = L[1][1]
secret_a3 = L[2][0]
secret_b3 = L[2][1]
secret_a4 = L[3][0]
secret_b4 = L[3][1]

